package com.alan.wifishare.view.impl;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Parcelable;

import com.alan.libapi.model.business.UserToken;
import com.alan.libapi.model.persistent.ModifyPwdType;
import com.alan.wifishare.view.impl.activity.CNTBindLinkScanActivity;
import com.alan.wifishare.view.impl.activity.CNTBindLinkSubmitActivity;
import com.alan.wifishare.view.impl.activity.CNTChangeLinkActivity;
import com.alan.wifishare.view.impl.activity.CNTConnectLinkActivity;
import com.alan.wifishare.view.impl.activity.CNTLinkManagerActivity;
import com.alan.wifishare.view.impl.activity.CNTManageConnectedDevicesActivity;
import com.alan.wifishare.view.impl.activity.MainActivity;
import com.alan.wifishare.view.impl.activity.SHAWifiScanActivity;
import com.alan.wifishare.view.impl.activity.SHAWifiSubmitActivity;
import com.alan.wifishare.view.impl.activity.UserGuideActivity;
import com.alan.wifishare.view.impl.activity.UserLoginActivity;
import com.alan.wifishare.view.impl.activity.UserModifyPwdActivity;
import com.alan.wifishare.view.impl.activity.UserRegisterActivity;
import com.alan.wifishare.view.impl.activity.UserVerifyIdentityActivity;

/**
 * @className: ActivityJumpUtil
 * @describtion: ActivityJumpUtil
 * @author: AlanWang
 * @email: 850267876@qq.com
 * @time: 2016/5/2 19:30
 */
public class ActivityJumpUtil {

    public class Extra{
        public static final String LINK_NAME = "link_name";
        public static final String DEVICE_INFO = "device_info";
        public static final String MODIFY_PWD_TYPE = "modify_pwd_type";
        public static final String MODIFY_PWD_TOKEN = "modify_pwd_token";
    }

    public class RequestCode{
        public static final int SHA_WIFI_SHARE_2_SCAN = 10001;
        public static final int SHA_WIFI_SCAN_2_SUBMIT = 10002;
        public static final int SHA_WIFI_SHARE_2_SUBMIT = 10003;

        public static final int CNT_MAIN_2_CONNECT = 10004;
    }

    public class ResultCode {
        public static final int CNT_CONNECT_LINK_2_CNT_MAIN = 20001;
    }

    public class Extra2SHAWifiSubmitAct{
        public static final String IS_ADD_WIFI = "is_add_wifi";
        public static final String WIFI_ID = "wifi_id";
        public static final String WIFI_NAME = "wifi_name";
        public static final String WIFI_PWD = "wifi_pwd";
        public static final String WIFI_MAC = "wifi_mac";
        public static final String WIFI_AREA_ID = "wifi_area_id";
        public static final String WIFI_LONGITUDE = "wifi_longitude";
        public static final String WIFI_LATITUDE = "wifi_latitude";
        public static final String WIFI_ADDRESS = "wifi_address";
    }

    //跳转至用户登录界面
    public static void jump2UserLoginAct(Activity context){
        Intent toUserLoginActIntent = new Intent(context, UserLoginActivity.class);
        context.startActivity(toUserLoginActIntent);
    }

    //跳转至用户注册界面
    public static void jump2UserRegisterAct(Activity context){
        Intent toUserRegisterActIntent = new Intent(context, UserRegisterActivity.class);
        context.startActivity(toUserRegisterActIntent);
    }

    //跳转至身份验证界面
    public static void jump2VerifyIdentityFindPwdAct(Activity context, ModifyPwdType modifyPwdType){
        Intent toUserVerifyIdentityFindPwdActIntent = new Intent(context, UserVerifyIdentityActivity.class);
        toUserVerifyIdentityFindPwdActIntent.putExtra(Extra.MODIFY_PWD_TYPE, modifyPwdType);
        context.startActivity(toUserVerifyIdentityFindPwdActIntent);
    }

    //跳转至身份验证界面
    public static void jump2UserModifyPwdAct(Activity context, ModifyPwdType modifyPwdType, UserToken userToken){
        Intent toUserModifyPwdActIntent = new Intent(context, UserModifyPwdActivity.class);
        toUserModifyPwdActIntent.putExtra(Extra.MODIFY_PWD_TYPE, modifyPwdType);
        toUserModifyPwdActIntent.putExtra(Extra.MODIFY_PWD_TOKEN, userToken);
        context.startActivity(toUserModifyPwdActIntent);
    }

    //跳转至用户引导界面
    public static void jump2UserGuideAct(Activity context){
        Intent toUserGuideActIntent = new Intent(context, UserGuideActivity.class);
        context.startActivity(toUserGuideActIntent);
    }

    //跳转至主界面
    public static void jump2MainAct(Activity context){
        Intent toMainActIntent = new Intent(context, MainActivity.class);
        context.startActivity(toMainActIntent);
    }

    //跳转至连接管理界面
    public static void jump2LinkManageAct(Context context, String linkName){
        Intent toLinkManageActIntent = new Intent(context, CNTLinkManagerActivity.class);
        toLinkManageActIntent.putExtra(Extra.LINK_NAME, linkName);
        context.startActivity(toLinkManageActIntent);
    }

    //跳转至Wifi扫描界面
    public static void jump2SHAWifiScanAct(Activity context){
        Intent toAddWifiIntent = new Intent(context, SHAWifiScanActivity.class);
        context.startActivityForResult(toAddWifiIntent, RequestCode.SHA_WIFI_SHARE_2_SCAN);
    }

    //添加Wifi跳转至Wifi提交界面
    public static void jump2SHAWifiSubmitActToAddWifi(Activity context, String wifiName, String wifiMac, int wifiAreaId,
                                                      double wifiLongitude, double wifiLatitude, String wifiAddress){
        Intent toSHAWifiSubmitActivityIntent = new Intent(context, SHAWifiSubmitActivity.class);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.IS_ADD_WIFI, true);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_ID, -1);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_NAME, wifiName);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_PWD, "");
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_MAC, wifiMac);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_AREA_ID, wifiAreaId);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_LONGITUDE, wifiLongitude);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_LATITUDE, wifiLatitude);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_ADDRESS, wifiAddress);
        context.startActivityForResult(toSHAWifiSubmitActivityIntent, RequestCode.SHA_WIFI_SCAN_2_SUBMIT);
    }

    //修改wifi跳转至wifi提交界面
    public static void jump2SHAWifiSubmitActToUpdateWifi(Activity context, int wifiId, String wifiName, String wifiPwd, String wifiMac,
                                                         int wifiAreaId, double wifiLongitude, double wifiLatitude, String wifiAddress){
        Intent toSHAWifiSubmitActivityIntent = new Intent(context, SHAWifiSubmitActivity.class);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.IS_ADD_WIFI, false);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_ID, wifiId);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_NAME, wifiName);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_PWD, wifiPwd);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_MAC, wifiMac);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_AREA_ID, wifiAreaId);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_LONGITUDE, wifiLongitude);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_LATITUDE, wifiLatitude);
        toSHAWifiSubmitActivityIntent.putExtra(Extra2SHAWifiSubmitAct.WIFI_ADDRESS, wifiAddress);
        context.startActivityForResult(toSHAWifiSubmitActivityIntent, RequestCode.SHA_WIFI_SHARE_2_SUBMIT);
    }

    //跳转至设备绑定的设备扫描界面
    public static void jump2BindLinkScanAct(Activity context){
        Intent toBindLinkScanActIntent = new Intent(context, CNTBindLinkScanActivity.class);
        context.startActivity(toBindLinkScanActIntent);
    }

    //跳转至设备绑定的设备扫描界面
    public static void jump2BindLinkSubmitAct(Activity context, String deviceInfo){
        Intent toBindLinkSubmitActIntent = new Intent(context, CNTBindLinkSubmitActivity.class);
        toBindLinkSubmitActIntent.putExtra(Extra.DEVICE_INFO, deviceInfo);
        context.startActivity(toBindLinkSubmitActIntent);
    }

    //跳转至连接设备界面
    public static void jump2ConnectLinkAct(Activity context){
        Intent toConnectLinkActIntent = new Intent(context, CNTConnectLinkActivity.class);
        context.startActivityForResult(toConnectLinkActIntent, RequestCode.CNT_MAIN_2_CONNECT);
    }


    //跳转至修改设备界面
    public static void jump2ChangeLinkAct(Activity context){
        Intent toChangeLinkActIntent = new Intent(context, CNTChangeLinkActivity.class);
        context.startActivity(toChangeLinkActIntent);
    }

    //跳转至修改设备界面
    public static void jump2ManageConnectedDeviceAct(Activity context){
        Intent toManageConnectedDeviceActIntent = new Intent(context, CNTManageConnectedDevicesActivity.class);
        context.startActivity(toManageConnectedDeviceActIntent);
    }
}
